<?php
/* 
 * Template grabber. Use as a base for writing a new grabber.
 */

class TemplateGrabber
{
  /**
   * Constructor
   * @param schedulesPath Absolute path to folder where schedules should be saved. With trailing slash /. 
   * @param logosPath Absolute path to folder where logos should be saved. With trailing slash /.
   */
  function TemplateGrabber($schedulesPath )
  {
    // Absolute path to this php file. Use this path to reference all other files you might need to import.
    $this->path = substr(__FILE__, 0, strrpos(__FILE__, '/')) . "/";
    require_once($this->path . "../inc/grabberObjects.php"); // Contains different objects you must use in your grabber
    require_once($this->path . "../../engine/inc/JSON.php"); // Contains json functions, in case this script is running under php4 (i e Tiger).
    $this->schedulesPath = $schedulesPath;
    $this->MAX_DAYS = 7;
  }
  
  /**
   * Should try to update channel list, grab data (schedules, logos) for all channels for the specified number of days.
   * Note that the channelArray might include channels that this grabber does not provide any data for, 
   * so you need to watch out for that.
   * @param channelArray Array of channel objects that the system wants data for.
   * @param numDays Number of days to grab data for. If your service can't provide the amount of days required, then just grab as much as you can.
   * @param overwrite If true, all old schedules should be overwritten. If false, try to only download schedules that have changed.
   * @return Return success object if grab succeeded, error object otherwise.
   */
  function grab($channelArray, $numDays, $overwrite = false)
  {
    return new Success();
  }
  
  /**
   * Grab only the schedule, not the logo, at specified date.
   * @param channel Channel object.
   * @param timestamp Timestamp indicating the requested date. (You might want to check that today plus timestamp is less than MAX_DAYS.)
   * @param overwrite If true, all old schedules should be overwritten. If false, try to only download schedules that have changed.
   * @return Return success object if grab succeeded, error object otherwise.
   */
  function grabScheduleForDate($channel, $timestamp, $overwrite = false)
  {
    return new Success();
  }
  
  /**
   * Grab logo for specified channel.
   * @param channel Channel object.
   * @param overwrite If true, the old logo should be overwritten. If false, try to only download a new logo if the logo has changed on the server.
   */
  function grabLogo($channel, $overwrite = false)
  {
    return new Success();
  }
  
  /**
   * Download and return the list of channels supported by this grabber.
   * Feel free to cache the channel list somewhere in your grabber folder, 
   * to avoid downloading the channel list from the server too often.
   * @return An array filled with channel objects that this grabber can download schedules for.
   */
  function getChannelList()
  {
    return new ChannelList("template");
  }
  
}
?>